$(function(){
	listenClick();
	setXiao();
	dbcli();
	postAjax();
	 
});

function postAjax(){

	var data = {};
	data.otherpageName='圣诞节test';
	data.otherpageSrc='/xlltest.html';
    $.ajax({
        type: "POST",
        dataType: "json",
        url: "http://127.0.0.1:8080/otherpage/addOtherpage",
        data: JSON.stringify(data),
        contentType: "application/json;charset=UTF-8",
        success: function(msg){

        }
    });
}
	
function setXiao(){
	$("#xiao").stop(true,true).animate({top:"23px",opacity: "1"},2500,function(){
		setTwo();
	});
}

function setTwo(){
	$("#two").stop(true,true).animate({top:"23px",opacity: "1"},2500,function(){
		setThree();
	});
}

function setThree(){
	$("#three").stop(true,true).animate({top:"23px",opacity: "1"},2500,function(){
		setSdkl();
	});
}

function setSdkl(){
	$("#sdkl").stop(true,true).animate({top:"53px",opacity: "1",display:"block"},2500,function(){
		
	});
}

function initAudio(){
	if($("#audio")[0].paused){
			
		}
}

function listenClick(){
	$("#bgm-pic").click(function(e){
		if($("#audio")[0].paused){
			$("#audio")[0].play();
			$("#bgm-pic").removeClass("pause");
			$("#bgm-pic").addClass("start");
		}else{
			$("#audio")[0].pause();
			$("#bgm-pic").removeClass("start");
			$("#bgm-pic").addClass("pause");		
		}
	});
	initAudio();
}
var clicksonws = 0;
		//监听事件 双击后开始下雪
		function dbcli(){
			//初始化触摸起点Y
			var initY = 0;
			//滑动结束时的位置
			var endY = 0;
			$("body").on('touchstart', function(e){
				var id = e.originalEvent.targetTouches[0];
				initY = id.pageY;
			});

			$("body").on("touchmove", function(e){
				var id = e.originalEvent.targetTouches[0];
				endY = id.pageY;
			});

			//判断上滑和下滑  上滑：开始下雪  下滑：暂停
			$("body").on("touchend", function(e){
				if(endY > 50 && (endY-initY) < -50 ){
					if(interval != null){
						endsnow();
					}else{
						startSnows();	
					}
					
				}
			});
		}

